<template>
<el-dialog @close="colse" title="审核" :visible="getAuditShow" width="30%" center>
    <el-switch style="display: block" v-model="value2" active-color="#13ce66" inactive-color="#ff4949" active-text="通过" inactive-text="不通过"></el-switch>

    <el-input v-if="!value2" v-model="reason" placeholder="请输入不通理由"></el-input>

    <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitaudit">确 定</el-button>
    </span>
</el-dialog>
</template>

<script>
import * as api from "../utils/api";
export default {
    name: "Audit",
    data() {
        return {
            reason: "",
            value2: "",
        };
    },
    methods: {
        open1() {
            this.$notify({
                title: "成功",
                message: "操作成功",
                type: "success",
            });
        },
        colse() {
            this.$store.dispatch("changeAuditDialogActions1");
        },
        submitaudit() {
            this.colse();
            this.open1();
            let checkData = this.$store.state.PreferentialData.checkData;
            let checkDataId = [];
            let active_status = "";
            if (this.value2) {
                active_status = "通过审核";
            } else {
                active_status = "未通过审核";
            }

            for (let i = 0; i < checkData.length; i++) {
                checkDataId.push(checkData[i].group_purchase_discount_id);
            }
            this.axios({
                url: api.gbuyApproveGroupPurchaseDiscount3,
                method: "post",
                data: {
                    group_purchase_discount_id: checkDataId,
                    no_pass_reason: this.reason,
                    active_status: active_status,
                },
            }).then((data) => {
                if (data.data.code === 200) {}
            });
        },
    },
    computed: {
        getAuditShow() {
            return this.$store.state.PreferentialData.AuditVisible;
        },
    },
};
</script>

<style>
.el-switch {
    text-align: center;
    margin-bottom: 20px;
}
</style>
